package com.MedDroid.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.MedDroid.MainApp;
import com.MedDroid.R;
import com.MedDroid.task.LoginTask;

/**
 * Created with IntelliJ IDEA.
 * User: Matt
 * Date: 29/11/13
 * Time: 11:18 PM
 * Description: Called from the main activity. Displays the login_page.xml layout
 * and runs the login page
 */
public class LoginActivity extends Activity
{
	public EditText EditUsername, EditPassword;
	public Button ButtonLogIn;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login_page);
	}

	@Override
	protected  void onResume()
	{
		super.onResume();
		EditPassword = (EditText) findViewById(R.id.editTextPassword);
		EditUsername = (EditText) findViewById(R.id.editTextUsername);
		ButtonLogIn = (Button) findViewById(R.id.buttonLogin);
		ButtonLogIn.setOnClickListener(new View.OnClickListener()
		{
			@Override
			public void onClick(View view)
			{
				//Just for testing it goes to the MainMenuActivity for now on log In button click
				//TODO elliot insert code here
				MainApp App = (MainApp)getApplication();
				new LoginTask(((MainApp) getApplication()).getAuthentication(), LoginActivity.this).execute(EditUsername.getText().toString(),EditPassword.getText().toString());
			}
		});
	}

	@Override
	public void onBackPressed() {
		finish();
	}

}